# a szokásos rutinok betöltése
%pylab inline
from scipy.integrate import * # az integráló rutinok betöltése
import matplotlib.pyplot as plt
from sympy.functions.special.delta_functions import Heaviside
import sympy
from IPython.core.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit"
value="Click here to toggle on/off the raw code."></form>''')
## Warning is ignored!!!!! Integration may be not too good.....
import warnings
warnings.filterwarnings("ignore")
(t)=sympy.symbols('t')
def idgaz_eta(VV,pp,gamma,Npont):
# idealis gazra
# hatasfok szamolasa
WW=pp * sympy.diff(VV,t)
qq=1/(gamma-1)*(VV*sympy.diff(pp,t)+gamma*pp*sympy.diff(VV,t))
q2= qq * Heaviside(qq)
Vn = lambda y:VV.subs({t:y}).n()
pn = lambda y:pp.subs({t:y}).n()
qn = lambda y:qq.subs({t:y}).n()
q2n = lambda y:q2.subs({t:y}).n()
WWn = lambda y:WW.subs({t:y}).n()
Qfel= quad(q2n,0,2*np.pi)
munka= quad(WWn,0,2*np.pi)
qpm=quad(qn,0,2*np.pi)
check = munka[0] - qpm[0]
eta=munka[0]/Qfel[0]
# adatok szamolasa az abrakhoz
fi=np.linspace(0,2*np.pi,Npont)
x = []
y = []
qfi = []
Thom = []
Sentropia = []
for i in range(len(fi)):
fii=fi[i]
x.append(Vn(fii))
y.append(pn(fii))
qfi.append(qn(fii))
Thom.append(Vn(fii)*pn(fii))
Sentropia.append(np.log(float(Vn(fii)*pn(fii)*Vn(fii))))
plt.figure(figsize=(20,6))
#vonalv = 4.0 # vonal vastagsag
#dashv = '--' # '-' -> solid, '--' -> szaggatott
# korfolyamat rajzolasa
plt.subplot(1,3,1,aspect='equal')
xmax=1.2*np.max(x)
ymax=1.2*np.max(y)
#type of xmax, ymax is string, must be converted to decimal !!!
plt.xlim(0,np.float(xmax))
plt.ylim(0,np.float(ymax))
plt.xlabel('V',fontsize=20)
plt.ylabel('p',fontsize=20)
#plt.plot(x,y,'r-',lw=3)
s=1
for i in range(0,Npont-s,s):
#print(qn(fi[i]))
if qn(fi[i]) > 0:
plt.plot(x[i:i+s+1],y[i:i+s+1],'r-',lw=3)
else:
plt.plot(x[i:i+s+1],y[i:i+s+1],'b--',lw=3)
# dQ/dt kirajzolas t fuggvenyeben
plt.subplot(1,3,2)
plt.plot(fi,qfi)
plt.xlim(0,2*np.pi)
plt.ylim(np.float(np.min(qfi)),np.float(np.max(qfi)))
plt.xlabel('t',fontsize=20)
plt.ylabel('dQ(t)/dt',fontsize=20)
plt.axis('on')
# (T,S) gorbe kirajzolasa
plt.subplot(1,3,3)
plt.plot(Sentropia,Thom)
plt.xlim(np.float(np.min(Sentropia)),np.float(np.max(Sentropia)))
plt.ylim(np.float(np.min(Thom)),np.float(np.max(Thom)))
plt.xlabel('S',fontsize=20)
plt.ylabel('T',fontsize=20)
return (eta,munka,Qfel,check)
($\gamma = \frac{c_p}{c_V} = 5/3$)
A p-V sÃkon a körfolyamatban a piros (folytonos) vonal hÅ‘felvételt, a kék (szaggatott) vonal hÅ‘leadást jelent.
# kor
gamma = 5 / 3; # gamma = cp/cV
V = 2.27 + 1 * sympy.sin(t)
p = 2.27 + 1 * sympy.cos(t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# kor
gamma = 5 / 3; # gamma = cp/cV
V = 1.02 + 1 * sympy.sin(t)
p = 1.02 + 1 * sympy.cos(t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# Cycloid of Ceva
gamma = 5 / 3; # gamma = cp/cV
V = 4 + (1 + 2*sympy.cos(2*t))*sympy.cos(t)
p = 3 - (1 + 2*sympy.cos(2*t))*sympy.sin(t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# rose
n=3
gamma = 5 / 3; # gamma = cp/cV
V = 2 + 2* sympy.cos(n*t)* sympy.cos(t)
p = 3 - 2* sympy.cos(n*t)*sympy.sin(t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# rose
n=5
gamma = 5 / 3; # gamma = cp/cV
V = 2 + 2* sympy.cos(n*t)* sympy.cos(t)
p = 3 - 2* sympy.cos(n*t)*sympy.sin(t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
#
gamma = 5 / 3; # gamma = cp/cV
V = 3/2 + sympy.cos(t)**3
p = 3/2 - sympy.sin(t)**3
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# nephroid
gamma = 5 / 3; # gamma = cp/cV
V = 5 + (3 * sympy.sin(t) - sympy.sin(3*t))
p = 5 + (3 * sympy.cos(t) - sympy.cos(3*t))
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# szivgorbe
gamma = 5 / 3; # gamma = cp/cV
V = 20 + 16 * (sympy.sin(t))**3
p = 20 + 13 * sympy.cos(t) - 5*sympy.cos(2*t) - 2*sympy.cos(3*t) - sympy.cos(4*t)
Npoints = 100
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])
# sajat
gamma = 5 / 3; # gamma = cp/cV
V = 5 + (3 * sympy.sin(t) - sympy.sin(3*t))
p = 5 + (3 * sympy.cos(t) - sympy.sin(3*t))
Npoints = 50
res=idgaz_eta(V,p,gamma,Npoints)
print('hatásfok = ',"%.4f" % res[0])
print('W = ',"%.3f" % res[1][0])
print('Qfel = ',"%.3f" % res[2][0])
print('check: Qfel- Qle-W = ',"%.7f" % res[3])